#ifndef CSONICANMATION_H
#define CSONICANMATION_H

#include <QWidget>
#include <QPainter>
#include <QPaintEvent>
#include <QPainterPath>
#include <QQueue>
#include <QGraphicsDropShadowEffect>

struct StCubic{
    StCubic(){}
    StCubic(QPointF &ptfHandle1,QPointF &ptfAnchor,QPointF &ptfHandle2)
    {
        this->ptfHandle1 = ptfHandle1;
        this->ptfAnchor = ptfAnchor;
        this->ptfHandle2 = ptfHandle2;
    }

    QPointF ptfHandle1;
    QPointF ptfAnchor;
    QPointF ptfHandle2; //暂时没用到
};

class CSonicAnmation : public QWidget
{
    Q_OBJECT
public:
    explicit CSonicAnmation(QWidget *parent = 0);


    void setData(QVector<int> &vecData); //设置声波数据 建议五个数即可 数越多波浪越多
protected:
    virtual void paintEvent(QPaintEvent *event);

private:
    QPainterPath calcCublic(QVector<int> vecData,QPainter &painter);
    void randX(QVector<StCubic> &vecCubic); //X坐标随机处理
    QColor randColor();
    QLinearGradient randLineGradient();
private:
    QWidget *parent=nullptr;
    QVector<QVector<int>> m_vecSonic; //存储几行声波数据 目前3层
    int m_nSpan;//每个波所占的宽度
    QGraphicsBlurEffect *blurEffect=nullptr;
};
#endif // CSONICANMATION_H
